package top.kaoshanji.p1ch02a;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 代码清单-p1ch02a-41页a：通过自动装配，将一个CompactDisc注入到CDPlayer之中
 * @author kaoshanji
 * ^_^
 * create time 2025/4/22 15:34
 */
@Component
public class CDPlayer implements MediaPlayer {

    private CompactDisc cd;

    @Autowired
    public CDPlayer(CompactDisc cd) {
        this.cd = cd;
    }

    @Override
    public void play() {
        cd.play();
    }

}
